package com.flbill.pojo.dto;

import com.flbill.pojo.entity.Expense;
import com.flbill.pojo.entity.Income;
import lombok.Data;
import java.time.LocalDate;
import java.time.LocalDateTime;
import com.fasterxml.jackson.annotation.JsonProperty;
@Data
public class TransactionsDTO {
    private Integer id;
    private LocalDate date;
    private String type;
    private float amount;
    @JsonProperty("class")
    private String _class;
    private String remark;

    public Expense getExpense() {
        Expense expense = new Expense();
        //将LocalDate转换为LocalDateTime
        expense.setExpenseTime(date.atStartOfDay());
        expense.setAmount(amount);
        expense.setRemark(remark);
        expense.setId(id);
        expense.setUpdateTime(LocalDateTime.now());
        expense.setExpenseClass(_class);
        return expense;
    }
    public Income getIncome() {
        Income income = new Income();
        //将LocalDate转换为LocalDateTime
        income.setIncomeTime(date.atStartOfDay());
        income.setAmount(amount);
        income.setRemark(remark);
        income.setId(id);
        income.setUpdateTime(LocalDateTime.now());
        income.setIncomeClass(_class);
        return income;
    }
}
